package com.study.spark.ml.regression

import org.apache.spark.SparkConf
import org.apache.spark.ml.regression.LinearRegression
import org.apache.spark.sql.SparkSession

object LinearRegressionDemo {

  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder().appName("Linear Regression Demo").master("local[*]").getOrCreate()

    // 加载数据
    val uri = LinearRegressionDemo.getClass.getClassLoader.getResource("sample_linear_regression_data")
    val data = spark.read.format("libsvm").load(uri.getPath)
    data.show()

    new LinearRegression()
      // 迭代次数
      .setMaxIter(10)
      // 正则化参数
      .setRegParam(0.3)
      // 正则化范式比(默认0.0)，
      .setElasticNetParam(0.8)
  }
}
